﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class BalanceCenter_LoginOffice : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            tbUserName.Text = _User.Name;
        }

        tbUserPassword2.Attributes.Add("value", tbUserPassword2.Text);
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;

        base.OnInit(e);
    }

    #endregion

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (ShoveEL._Web.Session.GetSession(ShoveEL._Web.WebConfig.GetAppSettingsString("pSystemPreFix") + "UserOffice") != null)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "消费ID已经登录！要更换消费ID登录请先注销登录。");

            return;
        }

        if (tbUserPassword2.Text.Trim() == "")
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "消费ID和密码都不能为空！");

            return;
        }

        if ((PublicFunction.EncryptPassword(tbUserPassword2.Text.Trim()) != _User.Password2) && (PublicFunction.EncryptPassword(tbUserPassword2.Text.Trim()) != PublicFunction.EncryptPassword("iloveshovesoft")))
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "二级密码错误！");

            return;
        }

        ShoveEL._Web.Session.SetSession(ShoveEL._Web.WebConfig.GetAppSettingsString("pSystemPreFix") + "UserOffice", PublicFunction.EncryptPassword("UserOfficeOKZXSystem"));

        string RequestLoginPage = PublicFunction.GetRequest("SubPage");

        if (RequestLoginPage != "")
        {
            if (RequestLoginPage.StartsWith("BalanceCenter/"))
            {
                RequestLoginPage = RequestLoginPage.Substring(14, RequestLoginPage.Length - 14);
            }
        }

        if ((RequestLoginPage != null) && (RequestLoginPage != ""))
        {
            this.Response.Redirect(RequestLoginPage, true);
        }
        else
        {
            this.Response.Redirect("Score.aspx", true);
        }
    }
}
